package com.example.jetpacktest.lifecycle

import android.content.Intent
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.view.View
import com.example.jetpacktest.R
import kotlinx.android.synthetic.main.activity_lifecycle_service.*

class LifecycleServiceActivity : AppCompatActivity(), View.OnClickListener {
    override fun onClick(v: View?) {
        when (v?.id) {
            R.id.life_cycle_service_start -> {
                startService(Intent(this@LifecycleServiceActivity, LifecycleService::class.java))
            }
            R.id.life_cycle_service_stop -> {
                stopService(Intent(this@LifecycleServiceActivity, LifecycleService::class.java))
            }
        }
    }

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_lifecycle_service)

        life_cycle_service_start?.setOnClickListener(this)
        life_cycle_service_stop?.setOnClickListener(this)
    }
}
